class Solution
{
public:
    vector<vector<int>> findWinners(vector<vector<int>> &matches)
    {
        unordered_map<int, int> loseCount;
        for (auto &match : matches)
        {
            if (!loseCount.count(match[0]))
            {
                loseCount[match[0]] = 0;
            }
            ++loseCount[match[1]];
        }
        vector<vector<int>> result(2, vector<int>());
        for (auto &[player, lose] : loseCount)
        {
            if (lose == 0)
            {
                result[0].push_back(player);
            }
            else if (lose == 1)
            {
                result[1].push_back(player);
            }
        }
        sort(result[0].begin(), result[0].end());
        sort(result[1].begin(), result[1].end());
        return result;
    }
};